#pragma once
#include "igamestate.h"
#include "../DeadlyShadowsLastHope/IListener.h"
#include "../DeadlyShadowsLastHope/Entity.h"
#include "../DeadlyShadowsLastHope/ObjectFactory.h"
#include "../DeadlyShadowsLastHope/ObjectManager.h"
#include "../SGD Wrappers/CSGD_Direct3D.h"
#include "../SGD Wrappers/CSGD_DirectInput.h"
#include "../SGD Wrappers/CSGD_TextureManager.h"
#include "../SGD Wrappers/CSGD_XAudio2.h"
#include "../DeadlyShadowsLastHope/MessageSystem.h"
#include "../DeadlyShadowsLastHope/EventSystem.h"
#include "../SGD Wrappers/SGD_String.h"
#include "../Bitmap Font/BitmapFont.h"
#include "../AnimationManager.h"
#include "../Enemies/CSpawnSystem.h"
#include "../ScoreTimer.h"
#include "HighScoresState.h"
#include "LevelState.h"

typedef CObjectFactory< TSTRING, CEntity >	CObjectFact;
class CGameplayState : public IGameState, IListener
{
public:
	struct Camera
	{
		int camPosX;
		int camPosY;
	};

private:
	Camera m_pCam;
	CGameplayState(void);
	~CGameplayState(void);
	CGameplayState(const CGameplayState&);
	void operator=(CGameplayState&);

	CEntity* m_pPlayer;
	CEntity* m_pSpin;
	CEntity* m_pShield;
	CEntity* m_pFlyingEnemy;
	CEntity* m_pDash;

	float m_fPlayerHealthScale;
	float m_fMaxAbilityTime;
	float m_fLifeLossScale;
	float spinTimer;
	int m_nLifeBarImgID;
	int m_nLifeBarFrameImgID;
	int m_nHealthCostImgID;
	int m_nSpinButtonImgID;

	CObjectFact*		m_pOF;
	CObjectManager*		m_pOM;
	CSGD_TextureManager* m_pTM;
	CSGD_DirectInput*	m_pDI;
	CSGD_Direct3D*		m_pD3D;
	CSGD_XAudio2*		m_pXA;
	CMessageSystem*		m_pMS;
	CEventSystem*		m_pES;
	CSpawnSystem*		m_pSS;	
	CAnimationManager*	m_pAM;
	CScoreTimer*		m_pST;

	bool		paused;
	int			curMove;
	CBitmapFont		m_pFont;
	int			m_nBackGroundMusicID;
	int				m_nBackGroundImgID;
	int			m_nPlayerAttackSFXID;
	bool			m_bSaved;
	int			m_nPlayerJumpSFXID;
	int			m_nPlayerDeathSFXID;
	int			m_nEnemyAttackSFXID;
	int			m_nEnemyDeathSFXID;
	int			m_nPlayerLandSFXID;
	int			m_nBossSummonSFXID;
	int			m_nBossAttackSFXID;
	int			m_nBossDeadSFXID;

	int spawnscount;


public:
	Camera		GetCamera(void)const{return m_pCam;}
	CEntity*	GetPlayer(void)const{return m_pPlayer;}
	void		SaveGame(char * szFilename);
	static		CGameplayState* GetInstance(void);
	void		Update(float fElapsedTime);
	void		Render(void);
	void		Enter(void);
	void		Exit(void);
	bool		Input(void);
	static void MessageProc(InMessage* pMsg);
	void		HandleEvent(CNEvent* pEvent);
	bool		GetPaused(void) { return paused; }
	void		SetPaused(bool p) { paused= p; }
	bool		LoadGame(const char* szFilename);
};

